/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2024-10-24
 * Time:23:29
 */
public class Test {
    class Solution {
        public int countSegments(String s) {
            s=s.trim();
            if(s==null||s.isEmpty()){
                return 0;
            }
            String[] str=s.split(" ");
            int count=0;
            for(int i=0;i<str.length;i++){
                //空格的不算，有可能多个空格
                if(str[i].isEmpty()){
                    continue;
                }
                count++;
            }
            return count;
        }
    }
}
